deep_unpack()[1] will unpack a variant and its children, but only up to one level.
lookup_value()[2] will directly search for a value with a linear scan.
Performing a deep_unpack() + lookup can be a more expensive operation when we are
looking for just a single value compared to just perform the lookup_value() directly
in C. Avoid the deep_unpack() usage when we perform a single check presence.
[1] https://gjs.guide/guides/glib/gvariant.html#deepunpack
[2] https://docs.gtk.org/glib/method.Variant.lookup_value.html
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2416>
this._aggregateProvider.connectObject('g-properties-changed',
(proxy, properties) => {
- if ('Realms' in properties.deep_unpack())
+ const realmsChanged = !!properties.lookup_value('Realms', null);
+ if (realmsChanged)
this._reloadRealms();
}, this);
}
this._reloadRealm(realm);
realm.connect('g-properties-changed', (proxy, properties) => {
- if ('Configured' in properties.deep_unpack())
+ const configuredChanged = !!properties.lookup_value('Configured', null);
+ if (configuredChanged)
this._reloadRealm(realm);
});
}
this._proxy_cdma = new BroadbandModemCdmaProxy(Gio.DBus.system, 'org.freedesktop.ModemManager1', path);
this._proxy.connect('g-properties-changed', (proxy, properties) => {
- if ('SignalQuality' in properties.deep_unpack())
+ const signalQualityChanged = !!properties.lookup_value('SignalQuality', null);
+ if (signalQualityChanged)
this._reloadSignalQuality();
});
this._reloadSignalQuality();
this._updateToken(token);
token.connect('g-properties-changed', (proxy, properties) => {
- if ('IsInserted' in properties.deep_unpack()) {
+ const isInsertedChanged = !!properties.lookup_value('IsInserted', null);
+ if (isInsertedChanged) {
this._updateToken(token);
if (token.IsInserted)
}
_onGeocluePropsChanged(proxy, properties) {
- let unpacked = properties.deep_unpack();
- if ("InUse" in unpacked)
+ const inUseChanged = !!properties.lookup_value('InUse', null);
+ if (inUseChanged)
this.notify('in-use');
}
g_interface_info: colorInfo,
});
this._proxy.connect('g-properties-changed', (p, properties) => {
- if ('NightLightActive' in properties.deep_unpack())
+ const nightLightActiveChanged = !!properties.lookup_value('NightLightActive', null);
+ if (nightLightActiveChanged)
this._sync();
});
this._proxy.init_async(GLib.PRIORITY_DEFAULT, null)
if (error) {
log(error.message);
} else {
- this._proxy.connect('g-properties-changed',
- (p, properties) => {
- const propertyNames = properties.deep_unpack();
- if ('Profiles' in propertyNames)
- this._syncProfiles();
- this._sync();
- });
+ this._proxy.connect('g-properties-changed', (p, properties) => {
+ const profilesChanged = !!properties.lookup_value('Profiles', null);
+ if (profilesChanged)
+ this._syncProfiles();
+ this._sync();
+ });
this._syncProfiles();
}
this._sync();
}
_onPropertiesChanged(proxy, properties) {
- let unpacked = properties.deep_unpack();
- if (!('Probing' in unpacked))
- return;
-
- this.probing = this._proxy.Probing;
- this.emit('probing-changed', this.probing);
+ const probingChanged = !!properties.lookup_value('Probing', null);
+ if (probingChanged) {
+ this.probing = this._proxy.Probing;
+ this.emit('probing-changed', this.probing);
+ }
}
_onDeviceAdded(proxy, emitter, params) {